package cate.game.activity.mooncake.msg;

import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.activity.mooncake.MooncakeActivity;
import cate.game.activity.mooncake.MooncakeChallenge;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBMooncake;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "月饼大作战挑战boss 请求")
public class MooncakeChallengeReq implements MsgInput {
    @NoteField("活动功能id")
    public int funcId;
    @NoteField("阵营id")
    public int campId;
    @NoteField("第几关")
    public int combatNum;
    @NoteField("是否扫荡")
    public boolean mop;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        MooncakeActivity single = cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (single == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        GameResult<MooncakeChallenge> result = single.challenge.challenge(campId, combatNum, mop);
        if (result.ok()) {
            result.data.noticeUpdate();
        } else {
            game.notice.message(cc.getRole(), result.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBMooncake.MOONCAKE_CHALLENGE_REQ;
    }
}
